import { defineStore } from 'pinia'

export const useUser = defineStore('user', {
    state:()=>{
        return{
            uname:'',
            pasd:'',
            path:'',
            cun:[]
        }
    },
    actions:{
        login(uname,pwd){
            this.uname = uname,
            this.pasd = pwd,
            this.path = '/work'
        },
        islogin(){
            return this.uname && this.pasd;
        },
        setPath(p){
            this.path = p
        },
        logout(){
            this.uname = ''
            this.pasd = ''
        },
        addCun(add){
            this.cun.push(add);
        },
        removCun(remov){
            this.cun = this.cun.filter(i=>i.list!=remov);
        }
    },
    persist: {
        enabled:true
     }
})
